<?php
/**
 * Created by PhpStorm.
 * User: dwf
 * Time: 2019-05-06 14:38
 */

namespace App\Http\Validate;

use Illuminate\Support\Facades\Validator;

/**
 * Class BaseValidate
 * @package App\Http\Validate
 */
class BaseValidate
{
    private $rule;
    private $message;
    protected $params;

    public function __construct($validate_method, $params)
    {
        $this->params = $params;
        $rule_list    = $this->$validate_method();
        $this->rule   = $rule_list['rule'];
        if (isset($rule_list['custom_message'])) {
            $this->message = $rule_list['custom_message'];
        } else {
            $this->message = [];
        }
    }

    public function check()
    {
        $res = Validator::make($this->params, $this->rule, $this->message);
        return $res;
    }
}